.data
	floatout: .string "Wert %f\n"		# string for result
	x: .float 12.0, 12.0, 3.0, 71.0		# first vector
	y: .float 19.0, 10.0, 111.0, 12.0	# second vector
	n: .long 4				# dimension

	result: .float 0.0			# result of scalar multiplication

.text
.globl main
main:
	leal x, %esi				
	movups (%esi), %xmm0			
	leal y, %esi
	movups (%esi), %xmm1
	
	mulps %xmm1, %xmm0			# multiplicate all values of x with y(x1*y1,x2*y2...)

	movups %xmm0, %xmm2			# move all values into %xmm2
	shufps $0x93, %xmm2, %xmm2		# shuffle values - (1,2,3,4) => (4,1,2,3)
	movl $1, %edi				# set startindex to 1, cause 3 values to add up

.addition:
	cmpl n, %edi				# if index reached dimension 4
	movss %xmm0, result			# save move value into result
	je print				# go to print

	addss %xmm2, %xmm0			# else add first value %xmm2 with first value %xmm0
	shufps $0x93, %xmm2, %xmm2		# shuffle values - (4,1,2,3) => (3,4,1,2)
	addl $1, %edi				# index + 1
	jmp .addition				# go to addition again

print:
	fld result				# print result
	fstpl (%esp)
	pushl $floatout				
	call printf

	movl $1, %eax				# exit
	int $0x80				# software interrupt